<?php

namespace App\Http\Controllers\Admin;

use App\Http\Controllers\Controller as BaseContoller;
use App\Http\Responses\CustomResponse;
use App\Services\common\LoginLogService;
use Illuminate\Http\Request;

/**
 * 登录控制器
 */
class LoginLogController extends BaseContoller
{
    /**
     * 列表
     *
     * @return \Illuminate\Contracts\Foundation\Application|\Illuminate\Contracts\View\Factory|\Illuminate\Contracts\View\View|\Illuminate\Foundation\Application
     */
    public function index(Request $request)
    {
        $list = LoginLogService::getPageData($request->all());

        return CustomResponse::success($list);
    }

    /**
     * 删除
     *
     * @return void
     */
    public function destroy(Request $request, $id)
    {
        $ids = explode(',', $id);
        $result = LoginLogService::destroy($ids);
        if ($result) {
            return CustomResponse::success($id, '删除成功');
        } else {
            return CustomResponse::error('删除失败');
        }
    }
}
